#include <iostream> 
#include <string>
#include <cstdio>
using namespace std;
int c[50050];
int n;
int lowbit(int i)
{
	return i&(-i);
}

int insert(int i,int x)
{
	while(i<=n){
		c[i]+=x;
		i+=lowbit(i);
	}
	return 0;
}

int getsum(int x)
{
	int sum=0;
	while(x>0){
		sum+=c[x];
		x-=lowbit(x);
	}
	return sum;
}

int main()
{
	int t;
	cin>>t;
	int num=1;
	while(t--){
		memset(c,0,sizeof(c));
		cin>>n;
		int temp;
		for(int i=1;i<=n;i++){
			scanf("%d",&temp);
			insert(i,temp);
		}
		string order;
		int a,b;
		cin>>order;
		cout<<"Case "<<num<<":"<<endl;
		while(order!="End"){
			
			cin>>a>>b;
			if(order=="Query"){
				printf("%d\n",getsum(b)-getsum(a-1));
			}
			else if(order=="Add"){
				insert(a,b);
			}
			else{
				insert(a,-b);
			}
			cin>>order;
		}
		num++;
	}
	return 0;
}
